package dto

import (
	"danmu/common"
	"danmu/model"
)

type FavoritesDto struct {
	Vid uint `json:"vid"`
	Title string `json:"title"`
	Cover string `json:"img"`
}

func ToFavoritesDto(favorites []model.Interactive) []FavoritesDto {
	DB :=common.GetDB()
	newFavorites := make([]FavoritesDto, len(favorites))
	for i := 0; i < len(favorites); i++ {
		var video = model.Video{}
		newFavorites[i].Vid = favorites[i].Vid
		//查询视频信息
		DB.Where("id = ? AND is_show = 1",favorites[i].Vid).First(&video)
		newFavorites[i].Title = video.Title
		newFavorites[i].Cover = video.CoverName
	}
	return newFavorites
}